package com.leapp.sk.ui.activity.classs

import android.os.Bundle
import android.support.v4.widget.SwipeRefreshLayout
import com.example.inter.RefreshLoadMoreInferface
import com.example.mvp.activity.BaseActivityMVP
import com.example.mvp.binder.BaseDataBinder
import com.example.mvp.view.CabcelSureDialog
import com.example.util.closeInput
import com.leapp.sk.R
import com.leapp.sk.app.SKApplication
import com.leapp.sk.bean.ClassAlbumEntity
import com.leapp.sk.binder.BaseBinder
import com.leapp.sk.view.AddAlbumDialog
import com.leapp.sk.viewdelegate.classs.ClassAlbumDelegate

/**
 * 班级相册
 * @author  chaohaipeng  on 2018/8/6.
 */
class ClassAlbumActivity :BaseActivityMVP<ClassAlbumDelegate>(), RefreshLoadMoreInferface, SwipeRefreshLayout.OnRefreshListener{
    /**
     * dialog
     */
    private var addAlbumDialog: AddAlbumDialog? = null
    private  val mutableListOf = mutableListOf<ClassAlbumEntity>()
    override fun initDate() {
        addAlbumDialog = AddAlbumDialog(this, R.style.dialog_style)
        for (i in 1..10){
            mutableListOf.add(ClassAlbumEntity())
        }
        viewDelegate.initAdapter(mutableListOf,this,this,addAlbumDialog)



    }

    override fun bindEvenListener() {
        addAlbumDialog?.setEventInterface(object :AddAlbumDialog.DialogEventInterface{
            override fun leftOnClick() {
            }

            override fun rightOnClick() {
                // 隐藏键盘
                try {
                    closeInput(SKApplication.getInstance(), window.decorView)
                } catch (e: Exception) {
                    e.printStackTrace()
                }

                val classAlbumEntity = ClassAlbumEntity()
                classAlbumEntity.albumName=addAlbumDialog?.getDialogContent()!!
                classAlbumEntity.url="aaa"
                mutableListOf.add(0,classAlbumEntity)
                viewDelegate.notifyAdapter()
            }

        })
    }

    override fun getDelegateClass(): Class<ClassAlbumDelegate> {
        return ClassAlbumDelegate::class.java
    }

    override fun getDataBinder(): BaseDataBinder<*, *> {
        return BaseBinder()
    }

    override fun initView(p0: Bundle?) {
        viewDelegate.setTitle(resources.getString(R.string.string_album_class_manager))
    }
    override fun loadMoreData() {


    }

    override fun onRefresh() {
        viewDelegate.stopSwipRefresh()
    }


}